package com.yunxin.core.application.assembler;

import com.yunxin.core.application.command.merchant.*;
import com.yunxin.core.application.dto.merchant.*;
import com.yunxin.core.domain.external.merchant.MerchantAccount;
import com.yunxin.core.domain.model.merchant.MerchantContactPerson;
import com.yunxin.core.domain.model.merchant.MerchantInfo;
import com.yunxin.core.domain.model.merchant.MerchantInvoiceInfo;
import com.yunxin.core.infra.persistence.entity.merchant.MerchantContactPersonDO;
import com.yunxin.core.infra.persistence.entity.merchant.MerchantInfoDO;
import com.yunxin.core.infra.persistence.entity.merchant.MerchantInvoiceInfoDO;
import com.yunxin.core.infra.persistence.entity.merchant.MerchantUserAccountDO;
import com.yunxin.core.infra.persistence.entity.merchant.query.condition.MerchantPageCondition;
import com.yunxin.core.infra.persistence.entity.merchant.query.result.MerchantAccountResult;
import com.yunxin.core.infra.persistence.entity.merchant.query.result.MerchantListResult;
import com.yunxin.core.infra.persistence.entity.merchant.query.result.MerchantPageResult;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * 商户对象转换器
 * @author zero°
 * @since 2023-05-27
 */
@Mapper(componentModel = "spring")
public interface MerchantAssembler {

    /**
     * result 转 dto
     * @param result result
     * @return MerchantListDTO
     */
    MerchantListDTO toMerchantListDTO(MerchantListResult result);

    /**
     * result 转 dto
     * @param result result
     * @return MerchantPageDTO
     */
    @Mapping(target = "merchantTypeStr", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getMerchantType(), com.yunxin.core.infra.common.merchant.enums.MerchantTypeEnum.class))")
    @Mapping(target = "merchantStatusStr", expression = "java(com.yunxin.common.base.IBaseEnum.getLabelByValue(result.getMerchantStatus(), com.yunxin.core.infra.common.merchant.enums.MerchantStatusEnum.class))")
    MerchantPageDTO toMerchantPageDTO(MerchantPageResult result);

    /**
     * entity 转 dto
     * @param entity entity
     * @return MerchantDetailDTO
     */
    MerchantDetailDTO toMerchantDetailDTO(MerchantInfoDO entity);

    /**
     * entity 转 dto
     * @param entity entity
     * @return MerchantContactPersonDTO
     */
    MerchantContactPersonDTO toMerchantContactPersonDTO(MerchantContactPersonDO entity);

    /**
     * entity 转 dto
     * @param entity entity
     * @return MerchantInvoiceDTO
     */
    MerchantInvoiceDTO toMerchantInvoiceDTO(MerchantInvoiceInfoDO entity);

    /**
     * result 转 dto
     * @param result result
     * @return MerchantAccountDTO
     */
    MerchantAccount toMerchantAccountDTO(MerchantAccountResult result);

    /**
     * entity 转 dto
     * @param entity entity
     * @return MerchantUserAccountDTO
     */
    MerchantUserAccountDTO toMerchantUserAccountDTO(MerchantUserAccountDO entity);

    /**
     * entity 转 dto
     * @param entity entity
     * @return MerchantUserAccountInfoDTO
     */
    MerchantUserAccountInfoDTO toMerchantUserAccountInfoDTO(MerchantUserAccountDO entity);


    /**
     * command 转 entity
     * @param command command
     * @return MerchantInfo
     */
    MerchantInfo fromAddMerchantCommand(AddMerchantCommand command);

    /**
     * command 转 entity
     * @param command command
     * @return MerchantInfo
     */
    MerchantInfo fromUpdateMerchantCommand(UpdateMerchantCommand command);

    /**
     * command 转 entity
     * @param command command
     * @return MerchantContactPerson
     */
    MerchantContactPerson fromMerchantContactPersonCommand(MerchantContactPersonCommand command);

    /**
     * command 转 entity
     * @param command command
     * @return MerchantInvoiceInfo
     */
    MerchantInvoiceInfo fromMerchantInvoiceCommand(MerchantInvoiceCommand command);
    /**
     * command 转 condition
     * @param command command
     * @return MerchantPageCondition
     */
    MerchantPageCondition fromMerchantPageCommand(MerchantPageCommand command);

}
